home *** CD-ROM | disk | FTP | other *** search
-
- (
- ( Very simple GUI example. This opens one window which contains only
- ( two buttons.
- (
-
- ( Variables, words etc. must not be defined more than once. ?& SIMPLE_GUI
- ( attempts to fetch the address of SIMPLE_GUI constant. If cannot be found
- ( we know that the program is loaded for the first time.
-
- ?& SIMPLE_GUI NOT ?IF
-
-
- ( define SIMPLE_GUI to make sure that these will not be defined again later.
-
- 1 CONSTANT SIMPLE_GUI
-
-
- ( this file contains necessary RPL definitions for GUI words.
-
- "ui.rpl" LOAD
-
-
- ( Variables, make sure these are unique. Conflicts with other RPL gui
- ( programs can crash the system.
-
- VARIABLE siaWindow
-
-
- ( Callbacks for buttons. When the user clicks buttons, these words
- ( are called.
-
- : sicbButton
- "I See" "Button Clicked" GET_KEY DROP
- ;
-
- : sicbHelp
- "r3d3:help/simple_gui.guide" "main" 0 AGUIDE
- ;
-
- : sicbClose
- siaWindow FETCH UI_DELETE ( delete the window
- NULL siaWindow STORE ( set siaWindow to NULL
- ;
-
-
- ( Callback for Window. Mouse movements, mouse clicks and close window
- ( events are reported.
-
- : sicbWindow
- PARAM
- VARIABLE iMouseY
- VARIABLE iMouseX
- VARIABLE iEvent
- ENDPARAM
-
- ( Check if iEvent is equal to UIWM_Close
- iEvent FETCH UIWM_Close =
- IF
- siaWindow FETCH UI_DELETE ( Close window
- NULL siaWindow STORE ( Set siaWindow to NULL
- ENDIF
- ;
-
- ?ENDIF
-
-
- ( Now that we have defined all the required variables and words it is time
- ( to create windows and other display elements.
-
- ( if window is already open, prompt proper error message and do nothing.
- siaWindow FETCH
- ?IF
- "Understood" "Window already opened" GET_KEY DROP
- ?ELSE
-
- ( otherwise, open all display elements
-
- ( Open a window
- UI_Done
- & sicbWindow 0 0 400 100 "Simple GUI Example" UI_WINDOW siaWindow STORE
-
- ( create button gadgets, no need to save handles
- UI_Done siaWindow FETCH & sicbButton 20 50 80 12 "Button" UI_BUTTON DROP
- UI_Done siaWindow FETCH & sicbHelp 100 50 80 12 "Help" UI_BUTTON DROP
- UI_Done siaWindow FETCH & sicbClose 220 50 130 12 "Close" UI_BUTTON DROP
-
- ( realize display elements
- siaWindow FETCH UI_REALIZE
-
- ?ENDIF
-